package com.le.tester.javaThink.fifth.chapter18_Str;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * createTime：2021/8/13 15:09
 * description：matcher中找到匹配
 */
public class Finding {
    public static void main(String[] args) {
        //Pattern.compile过滤掉一些规则(自己定义的正则表达式)，再进行matcher
        Matcher matcher = Pattern.compile("\\w+").matcher("Evening is full of the linnet's wings");

        while (matcher.find()) {
            System.out.print(matcher.group() + " ");
        }
        System.out.println();
        int i = 0;
        //索引从0开始匹配
        while (matcher.find(i)) {
            System.out.print(matcher.group() + " ");
            i++;
        }
    }
}
